/*用户中心-用户管理*/
import { routerRedux } from 'dva/router';
import * as LoginService from '../services/basics';

export default {
  namespace: 'userCenterUser',
  state: {
    data: [],
  },

  effects: {
  	//用户管理
  	//用户查看
    *fetch_centeruser({ payload }, { call, put }) {
      const response = yield call(LoginService.get,'/api/web/user/getUserList',payload);
      yield put({type: 'save',payload: response.data.obj});
    },
    //编辑用户
    *edit_organ_state({ payload, callback }, { call, put }) {
      const response = yield call(LoginService.get,'/api/web/org/updateOrgStates', payload);
     	callback(response.data.res,response.data.resMsg);
     	yield put({type:'fetch_centeruser'});
     },
     //用户添加立方币
    *add_lfb({ payload, callback }, { call, put }) {
      const response = yield call(LoginService.get,'/api/web/user/updateUserLfb', payload);
     	callback(response.data.res,response.data.resMsg);
     	yield put({type:'fetch_centeruser'});
     },
     //删除用户
    *remove_organ({ payload, callback }, { call, put }) {
      const response = yield call(LoginService.get,'/api/web/org/deleteOrgs', payload);
      callback(response.data.res,response.data.resMsg);
      yield put({type:'fetch_centeruser'});
    },
  },

  reducers: {
    save(state, action) {
      return {
        ...state,
        data: action.payload,
      };
    },
  },
};
